from otree.api import * from settings import PARTICIPANT_FIELDS author = "Nathaniel Archer Lawrence, LEMMA, Université Panthéon-Assas - Paris II" doc = """ Consumption simulation with interface based off of 'Shopping app (online grocery store)' from oTree demos, see: . """ class C(BaseConstants): NAME_IN_URL = '30_questions' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 # PERIODS = participant.periods_survived print('participant fields: ', PARTICIPANT_FIELDS) # print('periods type: ', type(PERIODS)) class Subsession(BaseSubsession): pass # def creating_session(subsession: Subsession): # for p in subsession.get_players(): # p.participant.periods_survived = periods_survived class Group(BaseGroup): pass class Player(BasePlayer): # for perceived inflation measures (inflation estimation and price memory) inflationEstimation = models.FloatField( # choices=[1 + i for i in range(-200, 200)], # Generate choices within predefined range # label='', #Over the course of the {} periods, by what percentage (%) would you estimate the price of the Basket of Goods changed? (In other words, what do you estimate was the overall inflation rate?'.format(player.participant.periods_survived), # min=-200, # max=200, # widget=widgets.RadioSelect ) priceMemory_1 = models.CurrencyField( label='What price did you pay in Period 1?', min=0, max=1000 ) priceMemory_2 = models.CurrencyField( label='What price did you pay in Period 10?', min=0, max=1000 ) priceMemory_3 = models.CurrencyField( label='What price did you pay in Period 20?', min=0, max=1000 ) priceMemory_4 = models.CurrencyField( label='What price did you pay in Period 30?', min=0, max=1000 ) # PAGES class Inflation_estimate(Page): form_model = 'player' form_fields = ['inflationEstimation'] class Price_memory(Page): form_model = 'player' @staticmethod def get_form_fields(player): if player.participant.periods_survived >= 30: return ['priceMemory_1','priceMemory_2','priceMemory_3','priceMemory_4',] elif player.participant.periods_survived >= 20: return ['priceMemory_1','priceMemory_2','priceMemory_3'] elif player.participant.periods_survived >= 10: return ['priceMemory_1','priceMemory_2'] else: return ['priceMemory_1'] # form_fields = ['priceMemory_1','priceMemory_2','priceMemory_3','priceMemory_4',] page_sequence = [Inflation_estimate, Price_memory]